﻿using BankTransfer.Bank.Domain.Messaging;
using BankTransfer.Bank.Infrastructure.Messaging.Service;
using BankTransfer.Bank.Types.Types;

namespace BankTransfer.Bank.Infrastructure.Messaging.Impl
{
    /// <summary>
    /// 发送审计消息
    /// </summary>
    public class AuditMessageProducerImpl : IAuditMessageProducer
    {
        private const string TOPIC_AUDIT_LOG = "TOPIC_AUDIT_LOG";
        private readonly KafkaTemplate kafkaTemplate;

        public AuditMessageProducerImpl(KafkaTemplate kafkaTemplate)
        {
            this.kafkaTemplate = kafkaTemplate;
        }

        public SendResult Send(AuditMessage message)
        {
            var msg = message.Serialize();
            kafkaTemplate.Send(TOPIC_AUDIT_LOG, msg);

            return SendResult.Success();
        }
    }
}